<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<input type="button" onclick="on()" value="开灯">
<img id="myImage" border="0" src="../img/010.jpeg" >
<input type="button" onclick="off()" value="关灯">

<script>


    function on() {
        document.getElementById('myImage').src='../img/010.jpeg';
    }
    function off() {
        document.getElementById('myImage').src='../img/011.jpeg';
    }

    var x=0;
    //根据一个变化的数据，产生固定个数的值：2  x%2
    //定时器
    setInterval(function () {
      if ( x %2==0){
          on();
      }else {
          off();
      }
      x++;
    },1000)
</script>

</body>
</html>